/**
 * Created by liuqingxia on 2016/2/26.
 */
$(document).ready(function () {
    var url = getRoot() + "/admin/user/insert";
    postRoleFormHttp("user-insert-form","commitBtn",url);
    
    //密码显示
    clickPasswordShow("passwdImgId","passwd");
});

function postRoleFormHttp(formId, commitBtnId, url) {
    var btnId = "#" + commitBtnId;
    $(document).on("click", btnId, function () {
        var params = getFormParams(formId);
        params['roleId'] = $("#roleInsertId option:selected").attr("id");
        try {
            $.postHttp(params, url, function (json) {
                if (json && json.success) {
                    swal("成功", json['message'], "success");
                } else {
                    if (json) {
                        swal("失败", json['message'], 'error');
                    }
                }
            })
        } catch (e) {
            swal("失败", "通信异常，请检查网络配置后重试", 'error');
        }
        return;
    });
}

